/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package familytree.struts.forms;

import familytree.persistencia.pojos.Usuario;
import javax.servlet.http.HttpServletRequest;

import java.util.ArrayList;
import java.util.Calendar;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import org.apache.struts.validator.ValidatorForm;

/**
 *
 * @author Antonio
 */
public class UsuarioForm extends ValidatorForm {

    private Usuario usuario;
    private String dia;
    private String mes;
    private String anyo;
    
    
    

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public UsuarioForm() {
    
        usuario = new Usuario();
    }

    public String getAnyo() {
        return anyo;
    }

    public void setAnyo(String anyo) {
        this.anyo = anyo;
    }

    public String getDia() {
        return dia;
    }

    public void setDia(String dia) {
        this.dia = dia;
    }

    public String getMes() {
        return mes;
    }

    public void setMes(String mes) {
        this.mes = mes;
    }
    
    
    
     
@Override
    public void reset(ActionMapping arg0, HttpServletRequest arg1)
    {
       ArrayList arrayDias = new ArrayList();
       ArrayList arrayMeses = new ArrayList();
       ArrayList arrayAnios = new ArrayList();
       String s ="";
       
       for(int i = 1;i<=31;i++){
          s = new Integer(i).toString();
          arrayDias.add(new LabelValueBean(s, s));
       }
       for(int i = 1; i<=12; i++)
       {
          s = new Integer(i).toString();
          arrayMeses.add(new LabelValueBean(s, s));
       }
       
       Calendar cal = Calendar.getInstance();
       int anyoActual = cal.get(Calendar.YEAR);
       
       for(int i = anyoActual; i >= 1900; i--)
       {
          s = new Integer(i).toString();
          arrayAnios.add(new LabelValueBean(s, s));
       }
       
       arg1.setAttribute("dias", arrayDias);
       arg1.setAttribute("mes", arrayMeses);
       arg1.setAttribute("anyo", arrayAnios);
    }
   

}
